package com.wn.date20190730;

import java.util.Scanner;

public class JudgeLeapYear
{

	public static void main(String[] args)
	{

		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入年份");
		int year = scanner.nextInt();
		boolean isLeapYear = IsLeapYear(year);
		if (isLeapYear)
		{
			System.out.println("年份为闰年");
		} else
		{
			System.out.println("不是闰年");
		}
		System.out.println("请输入月份");
		int month = scanner.nextInt();
		int days = getDays(year, month);
		System.out.println("天数：" + days);
		scanner.close();
	}

	// 判断天数
	public static int getDays(int y, int m)
	{

		int day;
		switch (m)
		{
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			day = 31;
			break;
		case 2:
			if (IsLeapYear(y))
			{
				day = 29;
			} else
			{
				day = 28;
			}
			break;
		default:
			day = 30;
			break;
		}
		return day;
	}

	// 判断是否闰年
	public static boolean IsLeapYear(int y)
	{

		if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
			return true;
		else
			return false;
	}

}
